package com.lamatek.tags.google;

import java.io.Serializable;

import javax.servlet.jsp.tagext.TagSupport;

/**
 * GoogleMapJavascriptTag
 * 
 * This tag represents a &lt;googlemaps:javascript> tag. Developers should not override or subclass
 * this class.
 * 
 * @author Tom Cole
 * @version 0.40
 */
public class GoogleMapJavascriptTag extends TagSupport implements Serializable {
    
    String id = null;
    String scope = "page";
    /**
     * Overrides doEndTag from TagSupport. Developers should not override this method.
     */
    public int doEndTag() {
        if (id != null) {
            Object o;
            if (scope.equalsIgnoreCase("site")) {
                o = pageContext.getSession().getAttribute(id);
            }
            else {
                o = pageContext.getAttribute(id);
            }
            if (o != null) {
                GoogleMapTag map = (GoogleMapTag) o;
                map.generateJavascript();
            }
        }
        return EVAL_PAGE;
    }
    /**
     * Sets the id of the parent &lt;googlemaps:map> that this tag initializes.
     * 
     * @param id A valid &lt;googlemaps:map> id value.
     */
    public void setId(String id) {
        this.id = id;
    }
    /**
     * Sets the scope where this &lt;div> should look for it's &lt;googlemaps:map>.
     * Valid values are "site" for session or "page" for pageContext.
     * 
     * @param scope A string (site OR page) that denotes session or pageContext.
     */
    public void setScope(String scope) {
        this.scope = scope;
    }
}
